package connection;

public class ServiceProxy implements connection.Service {
  private String _endpoint = null;
  private connection.Service service = null;
  
  public ServiceProxy() {
    _initServiceProxy();
  }
  
  public ServiceProxy(String endpoint) {
    _endpoint = endpoint;
    _initServiceProxy();
  }
  
  private void _initServiceProxy() {
    try {
      service = (new connection.ServiceServiceLocator()).getService();
      if (service != null) {
        if (_endpoint != null)
          ((javax.xml.rpc.Stub)service)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
        else
          _endpoint = (String)((javax.xml.rpc.Stub)service)._getProperty("javax.xml.rpc.service.endpoint.address");
      }
      
    }
    catch (javax.xml.rpc.ServiceException serviceException) {}
  }
  
  public String getEndpoint() {
    return _endpoint;
  }
  
  public void setEndpoint(String endpoint) {
    _endpoint = endpoint;
    if (service != null)
      ((javax.xml.rpc.Stub)service)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint);
    
  }
  
  public connection.Service getService() {
    if (service == null)
      _initServiceProxy();
    return service;
  }
  
  public java.lang.String deleteItemInCart(java.lang.String cartItemId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.deleteItemInCart(cartItemId);
  }
  
  public java.lang.String signIn(java.lang.String emailId, java.lang.String password) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.signIn(emailId, password);
  }
  
  public java.lang.String signUp(java.lang.String emailId, java.lang.String password, java.lang.String firstName, java.lang.String lastName) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.signUp(emailId, password, firstName, lastName);
  }
  
  public bean.TransactedItem[] getSoldItems(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getSoldItems(userId);
  }
  
  public bean.CartItem[] getUserCart(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getUserCart(userId);
  }
  
  public bean.Advertisement[] getUserCartItemDetails(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getUserCartItemDetails(userId);
  }
  
  public java.lang.String purchaseItemsInCart(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.purchaseItemsInCart(userId);
  }
  
  public bean.Advertisement[] getOtherAdvertisementExcludingId(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getOtherAdvertisementExcludingId(userId);
  }
  
  public java.lang.String updateItemInCart(java.lang.String cartItemId, java.lang.String orderedQuantity) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.updateItemInCart(cartItemId, orderedQuantity);
  }
  
  public java.lang.String checkAvailableQuantityForItemsInCart(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.checkAvailableQuantityForItemsInCart(userId);
  }
  
  public bean.Advertisement[] getOtherAdvertisement(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getOtherAdvertisement(userId);
  }
  
  public java.lang.String addAdvertisement(java.lang.String userId, java.lang.String itemName, java.lang.String itemDescription, java.lang.String itemPrice, java.lang.String itemQuantity, java.lang.String sellerInfo) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.addAdvertisement(userId, itemName, itemDescription, itemPrice, itemQuantity, sellerInfo);
  }
  
  public bean.Advertisement[] getMyAdvertisement(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getMyAdvertisement(userId);
  }
  
  public java.lang.String addItemToCart(java.lang.String userId, java.lang.String itemId, java.lang.String itemQuantity) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.addItemToCart(userId, itemId, itemQuantity);
  }
  
  public bean.TransactedItem[] getPurchasedItems(java.lang.String userId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.getPurchasedItems(userId);
  }
  
  public java.lang.String deleteMyAdvertisement(java.lang.String itemId) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.deleteMyAdvertisement(itemId);
  }
  
  public java.lang.String updateMyAdvertisement(java.lang.String itemId, java.lang.String itemQuantity) throws java.rmi.RemoteException{
    if (service == null)
      _initServiceProxy();
    return service.updateMyAdvertisement(itemId, itemQuantity);
  }
  
  
}